package com.bestcem.xm.member.mq;//package com.bestcem.xm.member.mq;
//
//import com.bestcem.xm.config.RabbitMqConstantConfig;
//import org.springframework.amqp.core.Binding;
//import org.springframework.amqp.core.BindingBuilder;
//import org.springframework.amqp.core.CustomExchange;
//import org.springframework.amqp.core.Queue;
//import org.springframework.amqp.rabbit.config.SimpleRabbitListenerContainerFactory;
//import org.springframework.amqp.rabbit.connection.ConnectionFactory;
//import org.springframework.amqp.rabbit.listener.RabbitListenerContainerFactory;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//
//import java.util.HashMap;
//import java.util.Map;
//
///**
// * 联系人 延迟队列
// *
// * @author yf.wang <yf.wang@idiaoyan.com>
// * @version V1.0
// * @date 2022/4/12
// */
//@Configuration
//public class MemberDelayRabbitConfig {
//
//    @Autowired
//    private RabbitMqConstantConfig rabbitMqConstantConfig;
//
//    /**
//     * java端联系人模块自发自收延迟消息的exchange
//     *     微信公众号打开与关闭
//     *     微信公众号授权
//     */
//    @Bean
//    public CustomExchange appMemberWechatMemberSyncDelayExchange() {
//        Map<String, Object> args = new HashMap<>();
//        args.put("x-delayed-type", "direct");
//        return new CustomExchange(rabbitMqConstantConfig.getAppMemberWechatMemberSyncDelayExchange(), "x-delayed-message", true, false, args);
//    }
//
//    /**
//     * java端联系人模块自发自收延迟消息的queue
//     *     微信公众号打开与关闭
//     *     微信公众号授权
//     */
//    @Bean
//    public Queue appMemberWechatMemberSyncDelayQueue() {
//        return new Queue(rabbitMqConstantConfig.getAppMemberWechatMemberSyncDelayQueue());
//    }
//
//    /**
//     * java端联系人模块自发自收延迟消息的routingKey
//     *     微信公众号打开与关闭
//     *     微信公众号授权
//     */
//    @Bean
//    public Binding appMemberWechatMemberSyncDelayBinding() {
//        return BindingBuilder.bind(appMemberWechatMemberSyncDelayQueue()).to(appMemberWechatMemberSyncDelayExchange()).with(rabbitMqConstantConfig.getAppMemberWechatMemberSyncDelayRoutingKey()).noargs();
//    }
//
//
//    /**
//     * java端联系人模块自发自收延迟消息的exchange
//     *     定时同步联系人
//     */
//    @Bean
//    public CustomExchange appMemberWechatMemberScheduleSyncDelayExchange() {
//        Map<String, Object> args = new HashMap<>();
//        args.put("x-delayed-type", "direct");
//        return new CustomExchange(rabbitMqConstantConfig.getAppMemberWechatMemberScheduleSyncDelayExchange(), "x-delayed-message", true, false, args);
//    }
//
//    /**
//     * java端联系人模块自发自收延迟消息的queue
//     *     定时同步联系人
//     */
//    @Bean
//    public Queue appMemberWechatMemberScheduleSyncDelayQueue() {
//        return new Queue(rabbitMqConstantConfig.getAppMemberWechatMemberScheduleSyncDelayQueue());
//    }
//
//    /**
//     * java端联系人模块自发自收延迟消息的routingKey
//     *     定时同步联系人
//     */
//    @Bean
//    public Binding appMemberWechatMemberScheduleSyncDelayBinding() {
//        return BindingBuilder.bind(appMemberWechatMemberScheduleSyncDelayQueue()).to(appMemberWechatMemberScheduleSyncDelayExchange()).with(rabbitMqConstantConfig.getAppMemberWechatMemberScheduleSyncDelayRoutingKey()).noargs();
//    }
//
//    @Bean
//    public RabbitListenerContainerFactory<?> appMemberWechatMemberSyncDelayFactory(ConnectionFactory connectionFactory) {
//        //SimpleRabbitListenerContainerFactory发现消息中有content_type有text就会默认将其转换成string类型的
//        SimpleRabbitListenerContainerFactory factory = new SimpleRabbitListenerContainerFactory();
//        factory.setPrefetchCount(2);
//        factory.setConnectionFactory(connectionFactory);
//        return factory;
//    }
//
//    @Bean
//    public RabbitListenerContainerFactory<?> appMemberWechatMemberScheduleSyncDelayFactory(ConnectionFactory connectionFactory) {
//        //SimpleRabbitListenerContainerFactory发现消息中有content_type有text就会默认将其转换成string类型的
//        SimpleRabbitListenerContainerFactory factory = new SimpleRabbitListenerContainerFactory();
//        factory.setPrefetchCount(2);
//        factory.setConnectionFactory(connectionFactory);
//        return factory;
//    }
//}
